/* eslint-disable @typescript-eslint/no-explicit-any */
import { CompressionSpec } from "../CompressionSpec";
import { BuiltInSensorType, IBuiltInSensor } from "../IBuiltInSensor";
import { ISensor } from "../ISensor";
import { ObservationSpec } from "../ObservationSpec";
import { ObservationWriter } from "../ObservationWriter";


export class ReflectionSensorInfo {
    public obj: object = null!;
    public sensorName: string = null!;
    public filedName: string = null!;
}

export abstract class ReflectionSensorBase implements ISensor, IBuiltInSensor {


    protected _object: object = null!;
    private _filedName: string = null!;
    private _sensorName: string = null!;
    private _observationSpec: ObservationSpec = null!;
    private _numFloats: number = 0;

    constructor(reflectionSensorInfo: ReflectionSensorInfo, size: number) {
        this._object = reflectionSensorInfo.obj;
        this._sensorName = reflectionSensorInfo.sensorName;
        this._filedName = reflectionSensorInfo.filedName;
        this._observationSpec = ObservationSpec.vector(size);
        this._numFloats = size;
    }
    getCompressedObservation(): Uint8Array {
        return new Uint8Array();
    }

    getBuiltInSensorType(): BuiltInSensorType {
        return BuiltInSensorType.ReflectionSensor;
    }
    getObservationSpec(): ObservationSpec {
        return this._observationSpec;
    }
    update(): void {

    }
    reset(): void {

    }
    getCompressionSpec(): CompressionSpec {
        return CompressionSpec.default();
    }

    getName(): string {
        return this._sensorName;
    }

    write(writer: ObservationWriter): number {
        this.writeReflectedField(writer);
        return this._numFloats;
    }

    abstract writeReflectedField(writer: ObservationWriter): void;

    /**
     * @en
     * Get either the reflected field, or return the reflected property.
     * 
     * @zh
     * 获取反射字段，或者返回反射属性。
     * @returns 
     */
    getReflectionValue(): any {
        return Reflect.get(this._object, this._filedName);
    }



}